package com.hmall.api.clients;

import com.hmall.api.clients.fallback.ItemClientFallback;
import com.hmall.api.config.DefaultFeignConfig;
import com.hmall.api.dto.ItemDTO;
import com.hmall.api.dto.OrderDetailDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.Collection;
import java.util.List;

/**
 * @projectName: hmall
 * @author: JiuQi
 * @description: item-service的接口
 * @date: 2024-11-12 20:35
 */
@FeignClient(value = "item-service",configuration = DefaultFeignConfig.class,fallbackFactory = ItemClientFallback.class) // fallbackFactory服务降级实现逻辑
public interface ItemClient {

    @GetMapping("/items")
    List<ItemDTO> queryItemByIds(@RequestParam("ids")Collection<Long> ids);

    @PutMapping("/items/stock/deduct")
    public void deductStock(@RequestBody List<OrderDetailDTO> items);

    @PutMapping("/items")
    public void updateItem(@RequestBody ItemDTO item);

    @GetMapping("/items/{id}")
    public ItemDTO queryItemById(@PathVariable("id") Long id);

    @PutMapping("items/stock/restore")
    public void restoreStock(@RequestBody List<OrderDetailDTO> items);
}
